package exercise.core;

import com.webserver.core.ClientHandler;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class V2ServerEX1 {
    private ServerSocket serverSocket;
    public V2ServerEX1(){
        System.out.println("qi dong zhong");
        try {
            serverSocket = new ServerSocket(8088);
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println("cheng gong qi dong");
    }
    public void start(){
        try {
            System.out.println("deng dai lian jie");
            Socket socket = serverSocket.accept();
            System.out.println("ke hu duan yi lian jie");
            ClientHandler handler = new ClientHandler(socket);
            Thread t = new Thread(handler);
            t.start();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        V2ServerEX1 v2ServerEX1 = new V2ServerEX1();
        v2ServerEX1.start();
    }
}
